async function check_perm(per_name, flag) {
    flag = flag || false;
    let now = Date.now();
    let appId = 'A6086660823294';
    let appKey = '18B51F5A-5D9B-143E-30FB-FAF804B457EF';
    appKey = hex_sha1(appId + "UZ" + appKey + "UZ" + now) + "." + now;
    let role = localStorage.role;
    let url = 'https://d.apicloud.com/mcm/api/admin_role?filter[where][role]=' + encodeURIComponent(role);
    let bbbb = true;
    let result = await new Promise((resolve, reject) => {
        $.ajax({
            "url": url,
            "method": "GET",
            "cache": false,
            "async": false,
            "headers": {
                "X-APICloud-AppId": appId,
                "X-APICloud-AppKey": appKey,
            },
            "success": function(data, status) {
                let qx;
                if (JSON.stringify(data) == '[]') {
                    qx = null;
                }
                else {
                    qx = data[0].role_list;
                }

                if (qx == null || qx == '' || qx == undefined) {
                    resolve(false);
                    return false
                }

                let qx_list = qx.split(',');

                if (flag) {
                    for (var i = 0; i < qx_list.length; i++) {
                        if (qx_list[i] == per_name) {
                            resolve(true);
                            break
                        }
                        if (i == qx_list.length - 1 && qx_list[i] != per_name) {
                            layui.use(['layer'], function() {
                                var layer = layui.layer;
                                layer.alert('你没有该访问权限！', { icon: 6 });
                                setTimeout(function() {
                                    location.href = 'sorry.html';
                                    resolve(false);
                                }, 2000);
                            })
                        }
                    }
                }
                else {
                    for (var i = 0; i < qx_list.length; i++) {
                        if (qx_list[i] == per_name) {
                            resolve(true);
                            break
                        }
                        if (i == qx_list.length - 1 && qx_list[i] != per_name) {
                            resolve(false);
                        }
                    }
                }
            }
        });
    });
    return result
}
